home *** CD-ROM | disk | FTP | other *** search
/ CD Actual Thematic 7: Programming / CDAT7.iso / demos / VisualAge for Java 2.0 Entry / setup / data1.cab / ide-e / IDE / cache / 1A8ZFFB (.txt) < prev    next >
Encoding:
Java Class File  |  1998-09-16  |  1.4 KB  |  28 lines

  1. package com.sun.java.swing.text;
  2.  
  3. import java.awt.event.ActionEvent;
  4.  
  5. class DefaultEditorKit$BeginParagraphAction extends TextAction {
  6.    private boolean select;
  7.  
  8.    DefaultEditorKit$BeginParagraphAction(String nm, boolean select) {
  9.       super(nm);
  10.       this.select = select;
  11.    }
  12.  
  13.    public void actionPerformed(ActionEvent e) {
  14.       JTextComponent target = ((TextAction)this).getTextComponent(e);
  15.       if (target != null) {
  16.          int offs = target.getCaretPosition();
  17.          Element elem = Utilities.getParagraphElement(target, offs);
  18.          offs = elem.getStartOffset();
  19.          if (this.select) {
  20.             target.moveCaretPosition(offs);
  21.          } else {
  22.             target.setCaretPosition(offs);
  23.          }
  24.       }
  25.  
  26.    }
  27. }
  28.